package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.expression.spel.ast.OperatorNot;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 菜品分页查询
     * @param dishPageQueryDTO
     * @return
     */
    Page<Dish> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 根据分类的id去查询菜品
     * @param categoryId
     * @return
     */
    @Select("select * from sky_take_out.dish where category_id=#{categoryId}")
    List<Dish> getByCategoryId(Long categoryId);

    /**
     * 根据菜品id去查询菜品
     * @param id
     * @return
     */
    @Select("select * from sky_take_out.dish where id=#{id}")
    Dish getById(Long id);

    /**
     * 修改菜品
     * @param dish
     */
    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);

    /**
     * 新增菜品
     * @param dish
     */
    @AutoFill(OperationType.INSERT)
    void insert(Dish dish);

    /**
     * 根据菜品分类id去查询菜品是否在起售
     * @param categoryId
     * @param status
     */
    @Select("select * from sky_take_out.dish where category_id=#{categoryId} and status=#{status}")
    List<Dish> getByCategoryIdAndStatus(Long categoryId, Integer status);

    /**
     * 根据套餐id查询菜品
     * @param setmealId
     * @return
     */
    List<Dish> getBySetmealId(Long setmealId);

    /**
     * 根据套餐id查询起售菜品
     * @param setmealId
     * @param status
     * @return
     */
    List<Dish> getBySetmealIdAndStatus(Long setmealId, Integer status);

    /**
     * 批量删除
     * @param ids
     */
    void delteBatch(List<Long> ids);
}
